const mongoose = require('mongoose');

// 用户名
const username = 'lightling';

// 密码
const password = '921108257';
// 数据库名称
const dbName = 'test';

// 连接数据库
const connectDB = async () => {
    try {
        await mongoose.connect(`mongodb://${username}:${password}@localhost:27017/${dbName}`, {
            useNewUrlParser: true,
            useUnifiedTopology: true
        });
        console.log('MongoDB 连接成功！');
    } catch (error) {
        console.error('MongoDB 连接失败:', error);
        process.exit(1);
    }
};

module.exports = connectDB;